package com.mengsenlin.serviceImpl;

import com.mengsenlin.entity.*;
import com.mengsenlin.mapper.GoodsMapper;
import com.mengsenlin.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * Created by Administrator on 2017/8/1.
 */
@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    GoodsMapper goodsMapper;

    public List<PollEntity> selectPollGoods(){
        return goodsMapper.selectPollGoods();
    }

    public List<TopEntity> selectTopGoods(){
        return goodsMapper.selectTopGoods();
    }

    public List<RecommendEntity> selectRecommendGoods(){
        return  goodsMapper.selectRecommendGoods();
    }

    public List<GoodsSpecification> selectGoodsSpe(long goodsId) {
        return goodsMapper.selectGoodsSpe(goodsId);
    }

    public List<CartItem> selectCartGoods(HttpSession session){
        User user = (User) session.getAttribute("user");
        long userId = user.getId();
//        System.out.println("userId="+userId);

        return goodsMapper.selectCartGoods(userId);
    }

    public List<DetailGoods> selectDetailGoods(long goodsId){
        return goodsMapper.selectDetailGoods(goodsId);
    }

    public DetailGoods selectUrlDetailGoods(long goodsId){
        return goodsMapper.selectUrlDetailGoods(goodsId);
    }

}
